package com.djhu.es.core.request;

import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;

/**
 * Created by zw on 2018/1/17.
 */
public class RangeSearchRequest extends AbstractRequest implements SearchRequest{
    private String field;
    private String key;
    @Override
    public QueryBuilder queryBuilder() {
        String[] strings = key.split(",");
        String from = strings[0];
        String to = strings[1];
        return QueryBuilders.rangeQuery(field).from(from).to(to);
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }
}